#include <stdio.h>
#include <sys/types.h>          /* See NOTES */
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <arpa/inet.h>
#include <stdlib.h>


int main(int argc, const char *argv[])
{
	int sockfd=socket(AF_INET,SOCK_STREAM,0);
	struct sockaddr_in serveraddr;
	serveraddr.sin_addr.s_addr=inet_addr(argv[1]);
	serveraddr.sin_port=htons(atoi(argv[2]));
	serveraddr.sin_family=AF_INET;

	socklen_t len =sizeof(serveraddr);
	connect(sockfd,(struct sockaddr *)&serveraddr,len);
	char sendbuf[256]={0};
	while(1)
	{
		fgets(sendbuf,256,stdin);
		sendbuf[strlen(sendbuf)-1]='\0';
		send(sockfd,sendbuf,256,0);
		memset(sendbuf,0,256);
	}

	return 0;
}
